package gui.applets;

import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Event;
import java.awt.TextArea;

public class AppletCheckBox extends Applet {
	TextArea ta = new TextArea(6, 20);
	Checkbox cb1 = new Checkbox("CheckBox 1");
	Checkbox cb2 = new Checkbox("CheckBox 2");
	Checkbox cb3 = new Checkbox("CheckBox 3");

	public void init() {
		add(ta);
		add(cb1);
		add(cb2);
		add(cb3);
	}

	public boolean action(Event evt, Object arg) {
		if (evt.target.equals(cb1)) {
			trace("1", cb1.getState());
		} else if (evt.target.equals(cb2)) {
			trace("2", cb2.getState());
		} else if (evt.target.equals(cb3)) {
			trace("3", cb3.getState());
		} else
			return super.action(evt, arg);
		return true;
	}

	private void trace(String str, boolean state) {
		if (state) {
			ta.appendText("Box" + str + "Set\n");
		} else {
			ta.appendText("Box" + str + "Cleared\n");
		}
	}

}
